package org.emavaj.sanguosha.model.card.basic.instance;

import java.util.List;

import org.emavaj.sanguosha.model.card.AbstractCard;
import org.emavaj.sanguosha.model.card.basic.BasicCard;
import org.emavaj.sanguosha.view.gameview.GameFrame;
import org.emavaj.sanguosha.view.gameview.OtherPlayerPane;

/**
 * 
 * @author eMavaj
 * 
 */
public class Attack extends BasicCard {

	@Override
	public void runCardEffect(GameFrame owner) {
		for (OtherPlayerPane pane : owner.getOtherPlayerPaneList()) {
			if (pane.isSelected()) {
				pane.setSelected(false);
				owner.offerCardTo(this, pane.getPlayer().getPlayerId());
			}
		}
	}

	@Override
	public boolean needsFeedBack() {
		return true;
	}

	@Override
	public boolean isFeedBackWork(AbstractCard card) {
		return card.getName().equals("闪");
	}

	/**
	 * 是否能出牌 1. 选择的玩家为1 2. 选择的牌为1 3. 选择的牌为杀
	 */
	@Override
	public boolean alreadyCanOffer(GameFrame owner) {
		//HandCardLabel selected = owner.getDashboard().getSeletedCards();
		//List<AbstractCard> cards = owner.getDashboard().getSeletedCards();
		return owner.getSelectedPlayerPane().size() == canSelectPlayerCount();
	}

	@Override
	public void canOfferTo(GameFrame owner) {
		// for (Player player : owner.getPlayers()) {
		// if (player.getPlayerId() == owner.getCurrentPlayerID()) {
		// continue;
		// }
		// }
		// 暂时不计算距离
		for (OtherPlayerPane pane : owner.getOtherPlayerPaneList()) {
			pane.setCanSelect(true);
		}
	}

	@Override
	protected boolean avaInPlayPhare(GameFrame owner) {
		return true;
	}

	@Override
	protected boolean avaInFeedBackPhare(GameFrame owner) {
		return owner.getDispatchInfo().checkFeedbackCard(this);
	}

	@Override
	public void hitTaget(GameFrame owner) {
		owner.getClient().sendDecreaseLifeInfo(owner.getCardTargetId(), 1);
	}

	@Override
	public boolean canOfferMore(List<AbstractCard> cardList) {
		// 暂时的实现
		return cardList.size() < 1;
	}
	
}
